<template>

    <div class="all">
      <input class="ipt" v-model="checkAll" @change="cbaChange" type="checkbox" id="all" />
      <label for="all">全选</label>
    </div>
    <div class="amount">
      <p>
        合计：<span>￥{{ amountAll }}元</span>
      </p>
      <!-- <span>合计：<em>￥0元</em> </span> -->
    </div>
    <div class="over">
      <p>
        结算<span>({{ countAll }})</span>
      </p>
    </div>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  computed: {
    ...mapGetters(['checkAll', 'amountAll', 'countAll']),
    checkAll: {
      get() {
        if (this.$store.state.list.every((item) => item.checked)) {
          return true
        } else {
          return false
        }
      },
      set(val) {
        if (this.$store.state.list.every((item) => item.checked)) {
          return val
        } else {
          return val
        }
      },
    },
  },
  methods: {
    cbaChange(e) {
      // console.log(e.target.checked)
      this.$store.commit('cbaChange', e.target.checked)
    },
  },
}
</script>

<style lang="less" scoped>

</style>
